home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / stdio / c / gets < prev    next >
Text File  |  1996-11-09  |  789b  |  35 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/stdio/c/RCS/gets,v $
  4.  * $Date: 1996/04/19 21:32:42 $
  5.  * $Revision: 1.1 $
  6.  * $State: Rel $
  7.  * $Author: simon $
  8.  *
  9.  * $Log: gets,v $
  10.  * Revision 1.1  1996/04/19 21:32:42  simon
  11.  * Initial revision
  12.  *
  13.  ***************************************************************************/
  14.  
  15. static const char rcs_id[] = "$Id: gets,v 1.1 1996/04/19 21:32:42 simon Rel $";
  16.  
  17. #include <stdio.h>
  18.  
  19. __STDIOLIB__
  20.  
  21. char *
  22. gets (register char *_s)
  23. {
  24.   register FILE *f = stdin;
  25.   register char *s = _s;
  26.   register int c = 0;
  27.  
  28.   while ((c = getc (f)) >= 0)
  29.     if ((*s++ = c) == '\n')
  30.       break;
  31.  
  32.   (c == '\n') ? (*--s = 0) : (*s = 0);
  33.   return ((c < 0 && s == _s) ? 0 : _s);
  34. }
  35.